<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Posting.Master" Inherits="System.Web.Mvc.ViewPage<mesoBoard.Data.Post>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">


    <div class="bread_crumb left">
        <%= Html.BreadCrumbThreadLink(0, Model.ThreadID)%>
    </div> 

    <fieldset>
        <legend><%= Html.ThemeImage("create_post.png") %> Edit Post</legend>
                    
            <% if(ViewData["Preview"] != null && (bool)ViewData["Preview"]){ %>
                <% Html.RenderPartial("PostPreview", Model) ;%>
            <%} %>
        
        <form action="" method="post" enctype="multipart/form-data">
            <dl class="form">
            
                <dt>
                    <label>Message</label>
                    <table class="smilies">
                        <% Html.RenderAction("GetSmilies", "Post", new { x = 4, z = 20 }); %>
                        <tr><th colspan="4">more smilies</th></tr>
                    </table>                    
                </dt>
                <dd>
                    <%= Html.TextArea("Text", new { @class="posting bbcode"}) %>
                    <%= Html.ValidationMessage("Text") %>
                </dd>
                                
                <% mesoBoard.Web.Models.UserPermissions perms = (mesoBoard.Web.Models.UserPermissions)ViewData["UserPermissions"]; %>
                <% if(perms.Attachment > 1){ %>

                    <dt>Attachments</dt>
                    <dd>
                        <div id="UploadFields">
                        <input type="file" name="file1" /><br />
                        <input type="file" name="file2" /><br />
                        </div>
                        <div id="UploadStatus">
                        </div>
                        <br />
                        <button type="button" id="ExtraUpload">Upload More</button>
                        <%= Html.ValidationMessage("FileSize") %>
                        <%= Html.ValidationMessage("FileType") %>
                        <% IEnumerable<Attachment> TheAttachments = (IEnumerable<Attachment>)ViewData["TheAttachments"]; %>
                        <% if(TheAttachments.Count() > 0){ %>
                        <div style="height: 150px; overflow: scroll; width: 500px;">
                            <% foreach(Attachment a in TheAttachments){ %>
                                <table class="post_single_attachment" style="width: 25%">
                                <tr><th><%= Html.FileTypeImage(System.IO.Path.GetExtension(a.DownloadName)) %> <%= a.DownloadName.Shorten(25) %></th></tr>
                                <tr><td>Size: <%= a.Size / 1024 %> kb</td></tr>
                                <tr><td>Downloaded: <%= a.Downloaded %> times</td></tr>
                                <tr><td>
                                <input type="checkbox" name="DeleteAttachments" value="<%= a.AttachmentID %>" id="Attachment<%= a.AttachmentID %>" />
                                <label for="Attachment<%= a.AttachmentID %>" class="inline">Delete</label>
                                </td></tr>
                                </table>
                            <%} %>
                        </div>
                        <%} %>
                    </dd>
                <%} %>
                
                <dt>Post Options</dt>
                <dd>
                    <input type="checkbox" name="SubscribeToThread" id="SubscribeToThread" value="true" <%= (bool)ViewData["IsSubscribed"] ? "checked" : ""  %> />
                    <label class="inline" for="SubscribeToThread">Subscribe to thread</label>
                    <br />
                    
                    <input type="checkbox" name="UseSignature" id="UseSignature" value="true" 
                    <%= Model.UseSignature || mbStuff.CurrentUser.UserProfile.AlwaysShowSignature ? "checked" : ""  %> />
                    <label class="inline" for="UseSignature">Use signature</label>
                </dd>
                        
                <dt>&nbsp;</dt>
                <dd>
                    <%= Html.Hidden("UserID") %>
                    <%= Html.Hidden("Date") %>
                    <%= Html.Hidden("ThreadID") %>
                    <%= Html.Hidden("PostID") %>
                    <%= Html.SubmitButton("SaveChanges", "Save Changes")%>
                    <button type="submit" name="Preview" value="true">Preview Post</button>
                    <%= Html.AntiForgeryToken() %>
                    <%= Html.ValidationMessage("TimeBetweenPosts") %>
                </dd>
            </dl>
        </form>
        <% Html.RenderAction("ThreadReview", "Post", new { ThreadID = Model.ThreadID }); %>
    </fieldset>
    


</asp:Content>
